import request from "@/utils/request";

/**
 * 获取用户列表
 * @param {Object} params 查询参数
 * @returns {Promise}
 */
export function getUserList(params) {
  return request({
    url: "/system/user/list",
    method: "get",
    params,
  });
}

/**
 * 添加用户
 * @param {Object} data 用户信息
 * @returns {Promise}
 */
export function addUser(data) {
  return request({
    url: "/system/user",
    method: "post",
    data,
  });
}

/**
 * 更新用户
 * @param {Object} data 用户信息
 * @returns {Promise}
 */
export function updateUser(data) {
  return request({
    url: `/system/user`,
    method: "put",
    data,
  });
}

/**
 * 删除用户
 * @param {number} id 用户ID
 * @returns {Promise}
 */
export function deleteUser(id) {
  return request({
    url: `/system/user/${id}`,
    method: "delete",
  });
}

/**
 * 重置用户密码
 * @param {number} id 用户ID
 * @returns {Promise}
 */
export function resetUserPassword(id) {
  return request({
    url: `/system/user/${id}/password/reset`,
    method: "put",
  });
}

/**
 * 获取用户角色列表
 * @returns {Promise}
 */
export function getRoleList() {
  return request({
    url: "/system/role/list",
    method: "get",
  });
}

/**
 * 获取用户信息
 * @returns {Promise}
 */
export function getUserInfo() {
  return request({
    url: "/system/user/info",
    method: "get",
  });
}
// 更新用户资料
export function updateUserProfile(data) {
  return request({
    url: "/system/user/profile",
    method: "put",
    data,
  });
}

// 修改用户密码
export function changePassword(data) {
  return request({
    url: "/system/user/password",
    method: "put",
    data,
  });
}
